﻿<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="TeacherList.aspx.cs" Inherits="Presentation.TeacherList"
    MasterPageFile="~/Site.Master" %>

<asp:Content ID="Content2" ContentPlaceHolderID="MainContent" runat="server">
    <script type="text/javascript">

        function GotoCreatePage() {
            window.location.href = "CreateTeacher.aspx";

            return false; //stop submit to server
        }

    </script>
    <style type="text/css">
        .style1
        {
            color: #0000FF;
            margin-top: 0px;
        }
    </style>
    <div class="style1">
        <fieldset class="bold" id="CreateTeacher">
            <legend>Teacher List</legend>
            <tr height="58px">
                <input type="button" value="Create New Teacher" onclick="GotoCreatePage();" />
                <%--button from client side--%>
                <%-- <asp:Button ID="Button_Create" runat="server" Text="Create New Teacher" 
              OnClientClick="return GotoCreatePage()" />--%>
            </tr>
            <br />
            <br />
            <tr>
                <asp:GridView ID="GridView1" runat="server" CellPadding="4" 
                ForeColor="#333333" GridLines="None"
                    AutoGenerateColumns="False" OnRowCommand="GridView1_RowCommand" Font-Bold="False"
                    PageSize="6">
                    <AlternatingRowStyle BackColor="White" ForeColor="#284775" />
                    <Columns>
                        <asp:BoundField DataField="TeacherId" HeaderText="Teacher Id" />
                        <asp:BoundField DataField="TeacherName" HeaderText="Teacher Name" />
                        <asp:BoundField DataField="TeacherGender" HeaderText="Teacher Gender" />
                        <asp:TemplateField HeaderText="Department">
                            <%--嵌套绑定--%>
                            <ItemTemplate>
                                <asp:Label ID="labDepartmentName" Text='<%# DataBinder.Eval(Container.DataItem,"DepartMent.DepartmentName") %>'
                                    runat="server"></asp:Label>
                            </ItemTemplate>
                        </asp:TemplateField>
                        <asp:TemplateField HeaderText="Operation">
                            <ItemTemplate>
                                <asp:Button ID="UpdateButton" runat="server" CausesValidation="false" CommandName="Update"
                                    Text="Update" CommandArgument='<%# Eval("TeacherId") %>' />
                                <asp:Button ID="DeleteButton" runat="server" CausesValidation="false" CommandName="DeleteRow"
                                    Text="Delete" CommandArgument='<%# Eval("TeacherId") %>' OnClientClick="return confirm('confirm to Delete?')" />
                            </ItemTemplate>
                        </asp:TemplateField>
                    </Columns>
                    <EditRowStyle BackColor="#999999" />
                    <FooterStyle BackColor="#5D7B9D" Font-Bold="True" ForeColor="White" />
                    <HeaderStyle BackColor="#5D7B9D" Font-Bold="True" ForeColor="White" />
                    <PagerStyle BackColor="#284775" ForeColor="White" HorizontalAlign="Center" />
                    <RowStyle BackColor="#F7F6F3" ForeColor="#333333" />
                    <SelectedRowStyle BackColor="#E2DED6" Font-Bold="True" ForeColor="#333333" />
                    <SortedAscendingCellStyle BackColor="#E9E7E2" />
                    <SortedAscendingHeaderStyle BackColor="#506C8C" />
                    <SortedDescendingCellStyle BackColor="#FFFDF8" />
                    <SortedDescendingHeaderStyle BackColor="#6F8DAE" />
                </asp:GridView>
            </tr>
            <tr align="center">
                <td align="left">
                    <asp:LinkButton ID="PreviousButton" runat="server" Text="< Previous" OnClick="PreviousButton_Click"></asp:LinkButton>
                </td>
                     &nbsp  &nbsp &nbsp &nbsp &nbsp &nbsp &nbsp  &nbsp &nbsp &nbsp &nbsp &nbsp &nbsp &nbsp &nbsp &nbsp &nbsp &nbsp
                <td align="right">
                    <asp:LinkButton ID="NextButton" runat="server" OnClick="NextButton_Click" Text="Next >"></asp:LinkButton>
                </td>
            </tr>
        </fieldset>
    </div>
</asp:Content>
